<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="楼凤名" prop="phoenixName">
        <el-input
          v-model="queryParams.phoenixName"
          placeholder="请输入楼凤名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="楼凤类型" prop="phoenixType">
        <el-select v-model="queryParams.phoenixType" placeholder="请选择楼凤类型" clearable size="small">
          <el-option label="请选择字典生成" value="" />
          <el-option label="楼凤" value="楼凤" />
          <el-option label="洗浴" value="洗浴" />
          <el-option label="会所" value="会所" />
          <el-option label="外围" value="外围" />
        </el-select>
      </el-form-item>








      <el-form-item label="楼凤状态" prop="phoenixState">
        <el-select v-model="queryParams.phoenixState" placeholder="请选择" clearable size="small">
          <el-option label="请选择" value="" />
          <el-option label="正常" value="0" />
          <el-option label="已锁定" value="1" />


        </el-select>
      </el-form-item>

      <el-form-item label="创建时间" prop="phoenixTime">
        <el-date-picker clearable size="small"
          v-model="queryParams.phoenixTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="primary"-->
<!--          plain-->
<!--          icon="el-icon-plus"-->
<!--          size="mini"-->
<!--          @click="handleAdd"-->
<!--          v-hasPermi="['xqsp:service:add']"-->
<!--        >新增</el-button>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="success"-->
<!--          plain-->
<!--          icon="el-icon-edit"-->
<!--          size="mini"-->
<!--          :disabled="single"-->
<!--          @click="handleUpdate"-->
<!--          v-hasPermi="['xqsp:service:edit']"-->
<!--        >修改</el-button>-->
<!--      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['xqsp:service:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['xqsp:service:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="serviceList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="楼凤id" align="center" prop="phoenixId" />
      <el-table-column label="楼凤名" align="center" prop="phoenixName" />
      <el-table-column label="标题信息" align="center" prop="phoenixTitle" />
      <el-table-column label="楼凤类型" align="center" prop="phoenixType" />
      <el-table-column label="楼凤数量" align="center" prop="phoenixNumber" />
      <el-table-column label="楼凤年龄" align="center" prop="phoenixAge" />
      <el-table-column label="楼凤职务" align="center" prop="phoenixWork" />
      <el-table-column label="服务项目" align="center" prop="phoenixServicesAvailable" />
      <el-table-column label="楼凤价格" align="center" prop="phoenixPrice" />
      <el-table-column label="楼凤服务时间" align="center" prop="phoenixServiceTime" />
      <el-table-column label="楼凤地址" align="center" prop="phoenixAddress" />
      <el-table-column label="楼凤详情介绍" :show-overflow-tooltip="true" align="center" prop="phoenixDetails" />
      <el-table-column label=" 楼凤评分" align="center" prop="phoenixScore" />
      <el-table-column label="楼凤联系方式" align="center" prop="phoenixPhone" />
      <el-table-column label="楼凤详细地址" align="center" prop="phoenixDetailedAddress" />
      <el-table-column label="楼凤观看人数" align="center" prop="phoenixWatchNumber" />
      <el-table-column label="楼凤点赞人数" align="center" prop="phoenixLikeNumber" />
      <el-table-column label="解锁金币数" align="center" prop="phoenixUnlockGold" />
      <el-table-column label="楼风解锁人数" align="center" prop="phoenixUnlockNumber" />
      <el-table-column label="楼凤上传图片" align="center" prop="phoenixImg">
        <template slot-scope="scope">
          <el-image :src="scope.row.phoenixImg"  :preview-src-list="[scope.row.phoenixImg]" style="width: 100px;height: 100px"/>
        </template>
      </el-table-column>
      <el-table-column label="楼凤状态" align="center" prop="phoenixState">
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.phoenixState"
            active-color="#13ce66"
            inactive-color="#ff4949"
            active-value="0"
            inactive-value="1"
            @change="handleStatusChange(scope.row)">
          </el-switch>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="phoenixTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.phoenixTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['xqsp:service:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['xqsp:service:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-s-comment"
            @click="handleEvaluation(scope.row)"
          >评价</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改楼凤操作对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="楼凤名" prop="phoenixName">
          <el-input v-model="form.phoenixName" placeholder="请输入楼凤名" />
        </el-form-item>
        <el-form-item label="标题信息" prop="phoenixTitle">
          <el-input v-model="form.phoenixTitle" placeholder="请输入标题信息" />
        </el-form-item>
        <el-form-item label="楼凤类型" prop="phoenixType">
          <el-select v-model="form.phoenixType" placeholder="请选择楼凤类型">
            <el-option label="请选择字典生成" value="" />
            <el-option label="楼凤" value="楼凤" />
            <el-option label="洗浴" value="洗浴" />
            <el-option label="会所" value="会所" />
            <el-option label="外围" value="外围" />
          </el-select>
        </el-form-item>
        <el-form-item label="楼凤数量" prop="phoenixNumber">
          <el-input v-model="form.phoenixNumber" placeholder="请输入楼凤数量" />
        </el-form-item>
        <el-form-item label="楼凤年龄" prop="phoenixAge">
          <el-input v-model="form.phoenixAge" placeholder="请输入楼凤年龄" />
        </el-form-item>
        <el-form-item label="楼凤职务" prop="phoenixWork">
          <el-input v-model="form.phoenixWork" placeholder="请输入楼凤职务" />
        </el-form-item>
        <el-form-item label="服务项目" prop="phoenixServicesAvailable">
          <el-input v-model="form.phoenixServicesAvailable" placeholder="请输入服务项目" />
        </el-form-item>
        <el-form-item label="楼凤价格" prop="phoenixPrice">
          <el-input v-model="form.phoenixPrice" placeholder="请输入楼凤价格" />
        </el-form-item>
        <el-form-item label="楼凤服务时间" prop="phoenixServiceTime">
          <el-input v-model="form.phoenixServiceTime" placeholder="请输入楼凤服务时间" />
        </el-form-item>
        <el-form-item label="楼凤地址" prop="phoenixAddress">
          <el-input v-model="form.phoenixAddress" placeholder="请输入楼凤地址" />
        </el-form-item>
        <el-form-item label="楼凤详情介绍" prop="phoenixDetails">
          <el-input v-model="form.phoenixDetails" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label=" 楼凤评分" prop="phoenixScore">
          <el-input v-model="form.phoenixScore" placeholder="请输入 楼凤评分" />
        </el-form-item>
        <el-form-item label="楼凤联系方式" prop="phoenixPhone">
          <el-input v-model="form.phoenixPhone" placeholder="请输入楼凤联系方式" />
        </el-form-item>
        <el-form-item label="楼凤详细地址" prop="phoenixDetailedAddress">
          <el-input v-model="form.phoenixDetailedAddress" placeholder="请输入楼凤详细地址" />
        </el-form-item>
        <el-form-item label="楼凤观看人数" prop="phoenixWatchNumber">
          <el-input v-model="form.phoenixWatchNumber" placeholder="请输入楼凤观看人数" />
        </el-form-item>
        <el-form-item label="楼凤点赞人数" prop="phoenixLikeNumber">
          <el-input v-model="form.phoenixLikeNumber" placeholder="请输入楼凤点赞人数" />
        </el-form-item>
        <el-form-item label="解锁金币数" prop="phoenixUnlockGold">
          <el-input v-model="form.phoenixUnlockGold" placeholder="请输入解锁金币数" />
        </el-form-item>
        <el-form-item label="楼风解锁人数" prop="phoenixUnlockNumber">
          <el-input v-model="form.phoenixUnlockNumber" placeholder="请输入楼风解锁人数" />
        </el-form-item>
        <el-form-item label="楼凤上传图片" prop="phoenixImg">
          <el-input v-model="form.phoenixImg" placeholder="请输入楼凤上传图片" />
        </el-form-item>
        <el-form-item label="创建时间" prop="phoenixTime">
          <el-date-picker clearable size="small"
            v-model="form.phoenixTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="选择创建时间">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

<!-- 楼凤评价-->
    <el-dialog :title="title" :visible.sync="open2" width="850px" append-to-body>
      <el-table v-loading="loading" :data="evaluationList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="评价编号" align="center" prop="spPhoenixEvaluation.phoenixEvaluationId" />
        <el-table-column label="楼凤id" align="center" prop="phoenixName" />
        <el-table-column label="用户id" align="center" prop="userName" />
        <el-table-column label="评价内容" align="center" :show-overflow-tooltip="true" prop="spPhoenixEvaluation.phoenixEvaluationContent" width="200" />
        <el-table-column label="评价时间" align="center" prop="spPhoenixEvaluation.phoenixEvaluationTime" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.spPhoenixEvaluation.phoenixEvaluationTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['xqsp:phoenixevaluation:edit']"
            >修改</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['xqsp:phoenixevaluation:remove']"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total1"
        :page.sync="queryParams1.pageNum"
        :limit.sync="queryParams1.pageSize"
        @pagination=" handleEvaluation(1)"
      />
      <div slot="footer" class="dialog-footer">

        <el-button @click="cancel2">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listService,updateServices, getService, delService, addService, updateService, exportService,updateServiceState ,updateServiceAudit} from "@/api/xqsp/service";
import { getEvaluationByPhoenixId  } from "@/api/xqsp/phoenixevaluation";

export default {
  name: "Service",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 楼凤操作表格数据
      serviceList: [],
      //楼凤评价
      evaluationList:[],
      // 弹出层标题
      title: "",
      phoenixId: null,
      // 是否显示弹出层
      open: false,
      open2:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        phoenixName: null,
        phoenixTitle: null,
        phoenixType: null,
        phoenixNumber: null,
        phoenixAge: null,
        phoenixWork: null,
        phoenixServicesAvailable: null,
        phoenixPrice: null,
        phoenixServiceTime: null,
        phoenixAddress: null,
        phoenixDetails: null,
        phoenixScore: null,
        phoenixWatchNumber: null,
        phoenixLikeNumber: null,
        phoenixUnlockGold: null,
        phoenixImg: null,
        phoenixState: null,
        phoenixAudit: null,
        phoenixTime: null,
        phoenixUnlockNumber: null,
        phoenixPhone: null,
        phoenixDetailedAddress: null
      },
      queryParams1: {
        pageNum: 1,
        pageSize: 10,
        phoenixId:null

      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询楼凤操作列表 */
    getList() {
      this.loading = true;
      listService(this.queryParams).then(response => {
        this.serviceList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        phoenixId: null,
        phoenixName: null,
        phoenixTitle: null,
        phoenixType: null,
        phoenixNumber: null,
        phoenixAge: null,
        phoenixWork: null,
        phoenixServicesAvailable: null,
        phoenixPrice: null,
        phoenixServiceTime: null,
        phoenixAddress: null,
        phoenixDetails: null,
        phoenixScore: null,
        phoenixWatchNumber: null,
        phoenixLikeNumber: null,
        phoenixUnlockGold: null,
        phoenixImg: null,
        phoenixState: null,
        phoenixAudit: null,
        phoenixTime: null,
        phoenixUnlockNumber: null,
        phoenixPhone: null,
        phoenixDetailedAddress: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.phoenixId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加楼凤操作";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const phoenixId = row.phoenixId || this.ids
      getService(phoenixId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改楼凤操作";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          console.log(this.form)
          if (this.form.phoenixId != null) {
            updateServices(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          }else {
            addService(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const phoenixIds = row.phoenixId || this.ids;
      this.$confirm('是否确认删除楼凤操作编号为"' + phoenixIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delService(phoenixIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有楼凤操作数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportService(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
    },

    // 是否锁定账户
    handleStatusChange(row) {
      let text = row.phoenixState === "0" ? "解锁" : "锁定";
      this.$confirm('确认要"' + text + '""' + row.phoenixName + '"吗?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function() {
        return updateServiceState(row.phoenixId, row.phoenixState);
      }).then(() => {
        this.msgSuccess(text + "成功");
      }).catch(function() {
        row.phoenixState = row.phoenixState === "0" ?" 1" : "0";
      });
    },
    // 是否同意
    handleAuditChange(row) {
      let text = row.phoenixAudit === "0" ? "不同意" : "同意";
      this.$confirm('确认要"' + text + '""' + row.phoenixName + '"的申请吗?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function() {
        return updateServiceAudit(row.phoenixId, row.phoenixAudit);
      }).then(() => {
        this.msgSuccess(text + "成功");
      }).catch(function() {
        row.phoenixAudit = row.phoenixAudit === "0" ? "1" : "0";
      });
    },
    /** 查看楼凤评价*/

    handleEvaluation(row){


      if (row!=1){
        this.phoenixId=row.phoenixId;
      }
      this.queryParams1.phoenixId=this.phoenixId;
      getEvaluationByPhoenixId(this.queryParams1).then(response => {

        this.evaluationList = response.rows;
        this.total1 = response.total;
        this.open2 = true;
        this.title =  "查看视频“"+row.phoenixName+"”的评价";

        this.loading = false;


      });
    },

  }
};
</script>
<style ang="scss">
  .el-tooltip__popper{
    max-width: 300px;
    font-size: 16px;
    background: #000 !important;/*背景色  !important优先级*/
    opacity: 0.8 !important;/*背景色透明度*/
    color: #FFFFFF !important;/*字体颜色*/
  }
</style>
